package com.dukang.notes

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.service.ApiInfo
import springfox.documentation.service.Contact
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2
import java.util.*

@SpringBootApplication
class NotesApplication

fun main(args: Array<String>) {
	runApplication<NotesApplication>(*args)
}


@Configuration
@EnableSwagger2
class SwaggerConfig {

	@Bean
	fun api(): Docket {
		return Docket(DocumentationType.SWAGGER_2)
			.select()
			.apis(RequestHandlerSelectors.any())
			.paths(PathSelectors.any())
			.build()
			.apiInfo(apiInfo())
	}

	private fun apiInfo(): ApiInfo {
		return ApiInfo(
			"杜康随手记接口文档",
			"方便开发者接口查询和测试",
			"api v1.0",
			"",
			Contact(
				"DealiAxy",
				"http://blog.deali.cn",
				"617259249@qq.com"
			),
			"GPL v2",
			"http://www.apache.org/",
			Collections.emptyList()
		)
	}
}
